package com.epower.web.action.app.web;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.epower.base.BaseAction;
import com.epower.bo.epower.commons.Constants;
import com.epower.bo.epowerbook.EpowerBookService;
import com.epower.dataobject.EpowerBookDO;

/**
 * @author bolin.hbc
 * 
 * 
 *         课本的action
 * 
 */
@Scope("prototype")
@Component("wbook")
public class BookAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private EpowerBookService epowerBookBO;

	private Integer id;
	private Integer liblevel;

	private EpowerBookDO epowerBook;

	private List<EpowerBookDO> bookList;

	public String doGetBookById() {

		if (id == null) {
			return ERROR;
		}

		epowerBook = epowerBookBO.getEpowerBookById(id);

		if (epowerBook == null) {
			return ERROR;
		}

		return SUCCESS;
	}

	public String doGetChildsById() {
		EpowerBookDO epowerBook = new EpowerBookDO();
		epowerBook.setPid(id);
		bookList = epowerBookBO.getEpowerBookIdsByOption(epowerBook);

		if (bookList == null && epowerBookBO.isBook(id)) {

			// 跳转到背单词的详情页面
		}
		return SUCCESS;
	}

	public String doGetBooksByLevel() {

		if (liblevel == null) {
			liblevel = Constants.DEFAULT_LIB_LEVEL;
		}
		EpowerBookDO epowerBook = new EpowerBookDO();
		epowerBook.setLiblevel(liblevel);
		bookList = epowerBookBO.getEpowerBookIdsByOption(epowerBook);

		return SUCCESS;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getLiblevel() {
		return liblevel;
	}

	public void setLiblevel(Integer liblevel) {
		this.liblevel = liblevel;
	}

 

	public EpowerBookDO getEpowerBook() {
		return epowerBook;
	}

	public void setEpowerBook(EpowerBookDO epowerBook) {
		this.epowerBook = epowerBook;
	}

	public List<EpowerBookDO> getBookList() {
		return bookList;
	}

	public void setBookList(List<EpowerBookDO> bookList) {
		this.bookList = bookList;
	}

	public void setEpowerBookBO(EpowerBookService epowerBookBO) {
		this.epowerBookBO = epowerBookBO;
	}

}
